package com.study.zzedu.ui.appointexam;


import android.content.Context;
import android.text.TextUtils;

import com.study.zzedu.base.BaseModel;
import com.study.zzedu.http.OnResultListener;
import com.study.zzedu.utils.AppConstant;
import com.study.zzedu.utils.LogUtil;
import com.study.zzedu.utils.OkHttpUtils;

import org.json.JSONArray;
import org.json.JSONObject;

public class AppointExamModel extends BaseModel {

    /*
    */
    public void getPhoneCode(Context context, final OnResultListener resultListener) {
        OkHttpUtils.getInstance(context).getJsonForString(OkHttpUtils.BASE_URL + "/code/getPhoneCode", null, null, new OkHttpUtils.HttpCallBack() {

            @Override
            public void onSuccess(String obj) {
                try {
                    JSONObject jObject = new JSONObject(obj);
                    if (0 == jObject.getInt("code")) {
                        JSONArray jsonArray = jObject.getJSONArray("data");
                        if (jsonArray.length() > 0) {
                            String uuid = jsonArray.getJSONObject(0).getString("uuid");
                            LogUtil.e("Forget", "codeUUID:" + uuid);
                            AppConstant.codeUUID = uuid;
                        }
                        resultListener.onSuccess(obj);
                    } else {
                        AppConstant.codeUUID = "";
                        resultListener.onError(jObject.get("message").toString());
                    }
                } catch (Exception e) {
                    e.toString();
                }
            }

            @Override
            public void onSuccess(JSONObject obj) {
                resultListener.onSuccess(obj.toString());
            }

            @Override
            public void onError(String msg) {
                AppConstant.codeUUID = "";
                resultListener.onError(msg);
            }
        });
    }


}
